import { configureStore } from "@reduxjs/toolkit"
import { useSelector } from "react-redux/es/hooks/useSelector"
import type { TypedUseSelectorHook } from "react-redux/es/types"
import counterReduer from "./modules/count"
import recommendReducer from "@/views/Discover/c-views/Recommend/store"
import playerReducer from "@/layout/AppPlayer/store"
const store = configureStore({
	reducer: {
		counter: counterReduer,
		recommend: recommendReducer,
		player: playerReducer,
	},
	middleware: (getDefaultMiddleware) => {
		console.log("IN MIDDLEWARE") // gets logged in tests, so jests gets to this point
		return getDefaultMiddleware({
			serializableCheck: false, // works in the app, but doesn't in tests - I still see the error log there
		})
	},
})

// 拿到getState返回值的ts类型
export type RootState = ReturnType<typeof store.getState>
// 通过泛型接口传递给useAppSelector函数
export const useAppSelector: TypedUseSelectorHook<RootState> = useSelector

export default store
